<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
<canvas id="demo" width="100" height="100"></canvas>

<script>
var canvas = document.getElementById('demo');
var context = canvas.getContext('2d');

context.fillStyle = 'rgba(255, 0, 0, .5)';
context.fillRect(0, 0, canvas.width, canvas.height);

var imageData = context.getImageData(0, 0, 2, 2);
console.log(imageData);
</script>
</body>
</html>
